﻿@using wne.models
@model FieldModel
@{
    Layout = null;
}
@functions {
    private MvcHtmlString getVariantForField(FieldModel fieldModel)
    {
        return new MvcHtmlString(fieldModel.AvaliableValues.Aggregate("", (prev, next) => prev + ";" + next));
    }

    private bool isShowVarField(FieldTypeEnum type)
    {
        return type == FieldTypeEnum.ManyOf || type == FieldTypeEnum.OneOf;
    }
}
<tr class="ParentGroupField">
    <td>
        <input type="text" class="fieldName" value="@Model.Name" title="Буквы и цифры" data-validation="date"/></td>
    <td>
        <select class="fieldType" onchange="fieldTypeChange($(this)) ">
            <option value="1" @((int)Model.Type == 1 ? "selected" : "")>Текстовое</option>
            <option value="2" @((int)Model.Type == 2 ? "selected" : "")>Числовое</option>
            <option value="3" @((int)Model.Type == 3 ? "selected" : "")>Да/Нет</option>
            <option value="4" @((int)Model.Type == 4 ? "selected" : "")>По выбору(одно из)</option>
            <option value="5" @((int)Model.Type == 5 ? "selected" : "")>По выбору(несколько из)</option>
            <option value="6" @((int)Model.Type == 6 ? "selected" : "")>Дата</option>
        </select>
        @if (Model.Type == FieldTypeEnum.ManyOf || Model.Type == FieldTypeEnum.OneOf)
        {
            <textarea type="text" class="fieldVariant" pattern="[A-Za-zА-Яа-яЁё0-9\s]{1,}+;">@Model.AvaliableValues.Values.Aggregate((prev, next) => prev + ";" + next)</textarea>
        }
    </td>
    <td>
        <input type="checkbox" class="fieldCanEdit" @(Model.UserCanEdit ? "checked" : "") />
    </td>
    <td>
        <input type="checkbox" class="fieldMandatory" @(Model.Mandatory ? "checked" : "") />
    </td>
    <td>
        <i class="icon-remove" onclick="deleteGroupField($(this));"></i>
</tr>
